home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl5
-
- # Apps.major.cgi
- # Silicon Graphics
-
- require "/usr/OnRamp/lib/OnRamp.pm";
- require "/usr/OnRamp/lib/java.pm";
-
- open(IN, "< ../admin/majordomo_data");
- while (<IN>) {
- chomp;
- ($key, $val) = split(/=/);
- $data{$key} = $val;
- }
- close(IN);
-
- $title = "Majordomo Mailing Lists";
- $myname = "Apps.major.cgi";
- $info_url = $ENV{'SERVER_URL'} . "/apps/major-info.cgi";
- $archive_url = $ENV{'SERVER_URL'} . "/apps/major-archive.cgi";
- $archive_dir = "$document_root/apps/majordomo";
- $lists_dir = "$data{'maj_home'}/lists";
- $aliases = "/etc/aliases";
-
- opendir(DIR, "$archive_dir");
- @archives = grep(!/^\.\.?$/, readdir(DIR));
- closedir(DIR);
- @archives = sort(@archives);
-
- opendir(DIR, "$lists_dir");
- @lists = grep(/^.*\.config$/, readdir(DIR));
- closedir(DIR);
- foreach $list (@lists) { $list =~ s/\.config//g; }
- @lists = sort(@lists);
-
- &get_fields;
-
- $js = "
- $js_error_box
- which = \"none\";
- function runSubmit() {
- form = document.Form;
- if (which == \"sub\" || which == \"uns\") {
- if (form.email.value == \"\") {
- errorBox(form.email, \"Email address required.\");
- return (false);
- }
- if (form.s_list.value == \"\") {
- errorBox(form.s_list, \"List name required.\");
- return (false);
- }
- }
- if (which == \"loc\") {
- if (form.email.value == \"\") {
- errorBox(form.email, \"Email address required.\");
- return (false);
- }
- }
- return (true);
- }
- function markSub() { which = \"sub\"; }
- function markUns() { which = \"uns\"; }
- function markLocate() { which = \"loc\"; }
- ";
-
- if ($fld{'locate'}) {
- $email = $fld{'email'};
- foreach $list (@lists) {
- $file = $lists_dir . "/" . $list;
- open(IN, "< $file");
- while(<IN>) {
- chop $_;
- push(@subsc, $list) if ($email eq $_);
- }
- close(IN);
- }
-
- } elsif ($fld{'subscribe'} || $fld{'unsub'}) {
- $email = $fld{'email'};
- $list = $fld{'s_list'};
- if ($fld{'subscribe'}) {
- &send_message("subscribe", $list, $email);
- $message .= "$email subscribed to $list.<br>\n";
- } else {
- &send_message("unsubscribe", $list, $email);
- $message .= "$email removed from $list.<br>\n";
- }
- }
-
- &generic;
-
- sub generic {
- print "Content-type: text/html\n\n";
- &js_title_block("Majordomo", $js);
- print "<body bgcolor=#B8E5C0 background=/apps/major.bg.gif>\n";
-
- open(IN, "< $aliases");
- while(<IN>) { $owner{$1} = $2 if ($_ =~ /^owner-(.*):\s+(.*)/); }
- close(IN);
-
- print "<table width=100%><tr><th align=left><h2>$title</h2></th>\n",
- "<th align=right><a href=\"/newsplash.shtml\">",
- "<img height=55 width=57 border=0 src=/apps/home.gif></a>\n",
- " <a href=\"Apps.shtml\">",
- "<img height=55 width=57 border=0 src=/apps/back.gif></a>",
- "</tr></table><br><br>\n<form name=Form method=post action=$myname ",
- "onSubmit=\"return runSubmit()\">\n";
-
- print "<font size=5><b><tt>Subscriptions:</tt></b></font><br>\n";
- print "<p><i>$message</i>\n";
-
- print "<center><table width=80%>\n";
- print "<tr align=left><th width=30%>Email address:<td width=20%>",
- &text("email", "", 15), "</td>\n";
- print "<td width=20%><input type=\"submit\" onClick=\"markSub()\" ",
- "name=\"subscribe\" value=\" Subscribe \"></td></tr>";
- print "<tr><th align=left width=30%>Mailing list:<td width=20%>",
- &text("s_list", "", 15), "</td>\n";
- print "<td width=20%><input type=\"submit\" onClick=\"markUns()\" ",
- "name=\"unsub\" value=\"Unsubscribe\"></td></tr>\n";
- print "<tr><th align=left colspan=2 width=50%>Locate mailing lists ",
- "currently subscribed to:\n";
- print "<td width=20%><input type=\"submit\" onClick=\"markLocate()\" ",
- "name=\"locate\" value=\" Search \"></td></tr>\n";
-
- if ($fld{'locate'}) {
- if ($#subsc == -1) {
- print "<tr><td colspan=3><i>$email is not subscribed to any "
- . "mailing lists on this server.</i><br></td></tr>\n"; }
- else {
- print "<tr><td colspan=3><i>$email is currently subscribed to: "
- . "</i><ul>\n";
- foreach (@subsc) {
- $url = $info_url . "?$_:$owner{$_}";
- print "<li><a href=$url>$_</a>\n";
- }
- print "</ul></td></tr>\n";
- }
- print "<br>\n";
- }
- print "</table></center>";
- print "<hr><br>\n";
-
- print "<font size=5><b><tt>Mailing lists:</tt></b></font><br>\n";
-
- if ($#lists > -1) {
-
- $third = ($#lists + 1)/3;
- if ($third =~ /([0-9]+)\./) { $third = $1; }
- $rem = ($#lists + 1) % 3;
- if ($rem == 0) { $a = $third; $b = $third; $c = $third; }
- elsif ($rem == 1) { $a = $third+1; $b = $third; $c = $third; }
- else { $a = $third+1; $b = $third+1; $c = $third; }
-
- print "<blockquote>\n";
- print "<table width=80%><tr><td valign=top><ul>";
- for ($i=0; $i<$a; $i++) {
- $url = $info_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a; $i<$a+$b; $i++) {
- $url = $info_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a+$b; $i<=$#archives; $i++) {
- $url = $info_url . "?$lists[$i]:$owner{$lists[$i]}";
- print "<li><a href=$url>$lists[$i]</a>\n";
- }
- print "</ul></td></tr></table>\n";
- print "</blockquote>\n";
-
- print "<hr><br>\n";
- } else {
- print "<center><table width=80%>\n";
- print "<tr><td><i><p><br>\n"
- . "There are currently no mailing lists."
- . "</i></td></tr>\n";
- print "</table></center>\n";
- }
-
- if ($#archives > -1) {
- print "<font size=5><b><tt>Message archives:</tt></b></font><br>\n";
-
- $third = ($#archives + 1)/3;
- if ($third =~ /([0-9]+)\./) { $third = $1; }
- $rem = ($#archives + 1) % 3;
- if ($rem == 0) { $a = $third; $b = $third; $c = $third; }
- elsif ($rem == 1) { $a = $third+1; $b = $third; $c = $third; }
- else { $a = $third+1; $b = $third+1; $c = $third; }
-
- print "<blockquote>\n";
- print "<table width=80%><tr><td valign=top><ul>";
- for ($i=0; $i<$a; $i++) {
- $url = $archive_url . "?$archives[$i]";
- print "<li><a href=$url>$archives[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a; $i<$a+$b; $i++) {
- $url = $archive_url . "?$archives[$i]";
- print "<li><a href=$url>$archives[$i]</a>\n";
- }
- print "</ul></td><td valign=top><ul>\n";
- for ($i=$a+$b; $i<=$#archives; $i++) {
- $url = $archive_url . "?$archives[$i]";
- print "<li><a href=$url>$archives[$i]</a>\n";
- }
- print "</ul></td></tr></table>\n";
- print "</blockquote>\n";
- print "<hr><br>\n";
- }
-
- print "</form></body></html>\n";
- }
-
- sub send_message {
- local ($body, $list, $email);
-
- $body = $_[0] . " " . $_[1];
- $email = $_[2];
-
- $cmd = "echo \"$body\" | /usr/lib/sendmail -f$email majordomo@" .
- $ENV{'SERVER_NAME'};
- system("$cmd > /dev/null 2>&1");
- }
-